<?php
class CubiertaTerminadasController extends AppController {
    public $helpers = array('Html', 'Form', 'Session', 'Javascript');
    public $components = array('Session');
    
    public function index() {
        $this->set('cubierta_terminadas', $this->CubiertaTerminada->find('all'));
    }
    
    public function view($id) {
        $this->CubiertaTerminada->id = $id;
        //$this->set('cubierta_terminada', $this->CubiertaTerminada->read());
    
      $this->set('cubierta_terminada', $this->CubiertaTerminada->find('list', array(
                  'fields' => array('id', 'name'), 
                  'order' => 'Inclusion.name', 
                  'recursive' => 0, )));

    }
    
    public function edit($id = null) {
         $this->CubiertaTerminada->id = $id;
    	if ($this->request->is('get')) {
    		$this->request->data = $this->CubiertaTerminada->read();
    	} else {
    		if ($this->CubiertaTerminada->save($this->request->data)) {
    			$this->Session->setFlash('Your post has been updated.');
    			$this->redirect(array('action' => 'index'));
    		} else {
    			$this->Session->setFlash('Unable to update your post.');
    		}
    	} 
    }
    
    public function add() {  
    	if ($this->request->is('post')) {
            $this->CubiertaTerminada->create();
            if ($this->CubiertaTerminada->save($this->request->data)) {
                $this->Session->setFlash('El cliente ha sido guardado.');
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash('Error al agregar el cliente.');
            }
        }
    }
    public function delete($id) {
    	//if ($this->request->is('get')) {
    	//	throw new MethodNotAllowedException();
    	//}
    	$this->CubiertaTerminada->id = $id;
    	$this->set('cubierta_terminada', $this->CubiertaTerminada->delete($id));
    	$this->redirect(array('action' => 'index'));
    	if ($this->CubiertaTerminada->delete($id)) {
    		$this->Session->setFlash('The cubierta_terminada with id: ' . $id . ' has been deleted.');
    		$this->redirect(array('action' => 'index'));
    	}
    }
    
}